<!DOCTYPE html>
<html>
<head>
    <title>Comment Node Example</title>
</head>
<body>
    <div id="myDiv"><!-- A comment --></div>
    <input type="button" value="Get Comment" onclick="getComment()">

    <script type="text/javascript">
        function getComment(){
        
            var div = document.getElementById("myDiv");
            var comment = div.firstChild;
            alert(comment.data);
            
        }

    </script>
</body>
</html>